-- Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved.
--
-- this file licensed under the Mulan PSL v2.
-- You can use this software according to the terms and conditions of the Mulan PSL v2.
-- You may obtain a copy of Mulan PSL v2 at: http://license.coscl.org.cn/MulanPSL2
--
-- THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
-- PURPOSE.
-- See the Mulan PSL v2 for more details.
--
-- Author: auto generate
-- Create: 2025-10-19
-- Description: DO NOT EDIT; Code generated by "model.lua.mako"
local mdb = require 'mc.mdb'
local class = require 'mc.class_mgnt'
local privilege = require 'mc.privilege'

local can_mgmt_class_types = require 'class.types.CANMgmt'
local data_sync_class_types = require 'class.types.DataSync'
local property_sync_class_types = require 'class.types.PropertySync'
local tcp_mgmt_class_types = require 'class.types.TCPMgmt'
local sync_destination_class_types = require 'class.types.SyncDestination'
local file_sync_class_types = require 'class.types.FileSync'
local data_sync_intf_types = require 'bmc_datasync.json_types.DataSync'
local properties_intf_types = require 'bmc_datasync.json_types.Properties'

local CANMgmt = {
    ['prop_configs'] = {
        ['Identifier'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'U8',
            ['default'] = 255,
            ['validator'] = can_mgmt_class_types.Identifier
        },
        ['Channels'] = {['usage'] = {'CSR'}, ['baseType'] = 'U8[]', ['validator'] = can_mgmt_class_types.Channels},
        ['Enabled'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'Boolean',
            ['default'] = false,
            ['validator'] = can_mgmt_class_types.Enabled
        }
    },
    ['default_props'] = {
        ['Identifier'] = 255,
        ['Channels'] = can_mgmt_class_types.Channels.default[1],
        ['Enabled'] = false
    }
}

local DataSync = {
    ['prop_configs'] = {
        ['CommunicationType'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'U8',
            ['default'] = 0,
            ['validator'] = data_sync_class_types.CommunicationType
        }
    },
    ['default_props'] = {['CommunicationType'] = 0},
    ['mdb_prop_configs'] = {
        ['bmc.kepler.Managers.DataSync'] = {},
        ['bmc.kepler.Object.Properties'] = {
            ['ClassName'] = {
                ['baseType'] = 'String',
                ['readOnly'] = true,
                ['validator'] = properties_intf_types.ClassName
            },
            ['ObjectName'] = {
                ['baseType'] = 'String',
                ['readOnly'] = true,
                ['validator'] = properties_intf_types.ObjectName
            },
            ['ObjectIdentifier'] = {
                ['baseType'] = 'Struct',
                ['$ref'] = '#/defs/StructIdentifier',
                ['readOnly'] = true,
                ['validator'] = properties_intf_types.ObjectIdentifier
            }
        }
    },
    ['mdb_method_configs'] = {
        ['bmc.kepler.Managers.DataSync'] = {
            ['GetProperties'] = {
                ['req'] = {
                    {['baseType'] = 'U8', ['param'] = 'Identifier'},
                    {['baseType'] = 'String', ['param'] = 'ObjectName'},
                    {['baseType'] = 'String', ['param'] = 'Interface'}
                },
                ['rsp'] = {
                    {['baseType'] = 'Array', ['items'] = {['$ref'] = '#/defs/SyncProperties'}, ['param'] = 'Properties'}
                }
            }
        }
    },
    ['mdb_signal_configs'] = {
        ['bmc.kepler.Managers.DataSync'] = {
            ['PropertyUpdated'] = {
                {['baseType'] = 'U8', ['param'] = 'Identifier'}, {['baseType'] = 'String', ['param'] = 'ObjectName'},
                {['baseType'] = 'String', ['param'] = 'Interface'}
            }
        }
    },
    ['mdb_classes'] = mdb.get_class_obj('/bmc/kepler/Managers/:ManagerId/DataSync'),
    ['new_mdb_objects'] = mdb.new_objects_builder({
        ['bmc.kepler.Managers.DataSync'] = {['property_defaults'] = {}, ['interface_types'] = data_sync_intf_types},
        ['bmc.kepler.Object.Properties'] = {
            ['property_defaults'] = {
                ['ClassName'] = properties_intf_types.ClassName.default[1],
                ['ObjectName'] = properties_intf_types.ObjectName.default[1],
                ['ObjectIdentifier'] = properties_intf_types.ObjectIdentifier.default[1]
            },
            ['interface_types'] = properties_intf_types
        }
    })
}

local PropertySync = {
    ['prop_configs'] = {
        ['SyncMode'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'U8',
            ['default'] = 0,
            ['validator'] = property_sync_class_types.SyncMode
        },
        ['SyncInterval'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'U8',
            ['default'] = 5,
            ['validator'] = property_sync_class_types.SyncInterval
        },
        ['TTL'] = {['usage'] = {'CSR'}, ['baseType'] = 'U32', ['validator'] = property_sync_class_types.TTL},
        ['SyncObjectName'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'String',
            ['default'] = '',
            ['validator'] = property_sync_class_types.SyncObjectName
        },
        ['SyncObjectItems'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'Array',
            ['items'] = {['baseType'] = 'Struct', ['$ref'] = 'types.json#/defs/SyncObjectItem'},
            ['validator'] = property_sync_class_types.SyncObjectItems
        }
    },
    ['default_props'] = {
        ['SyncMode'] = 0,
        ['SyncInterval'] = 5,
        ['TTL'] = property_sync_class_types.TTL.default[1],
        ['SyncObjectName'] = '',
        ['SyncObjectItems'] = property_sync_class_types.SyncObjectItems.default[1]
    }
}

local TCPMgmt = {
    ['prop_configs'] = {
        ['Enabled'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'Boolean',
            ['default'] = false,
            ['validator'] = tcp_mgmt_class_types.Enabled
        },
        ['Identifier'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'U8',
            ['default'] = 255,
            ['validator'] = tcp_mgmt_class_types.Identifier
        },
        ['Address'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'String',
            ['default'] = '',
            ['validator'] = tcp_mgmt_class_types.Address
        },
        ['Port'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'U16',
            ['default'] = 51000,
            ['validator'] = tcp_mgmt_class_types.Port
        },
        ['SyncRole'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'U8',
            ['default'] = 0,
            ['validator'] = tcp_mgmt_class_types.SyncRole
        }
    },
    ['default_props'] = {
        ['Enabled'] = false,
        ['Identifier'] = 255,
        ['Address'] = '',
        ['Port'] = 51000,
        ['SyncRole'] = 0
    }
}

local SyncDestination = {
    ['prop_configs'] = {
        ['Address'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'String',
            ['default'] = '',
            ['validator'] = sync_destination_class_types.Address
        },
        ['Port'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'U16',
            ['default'] = 51000,
            ['validator'] = sync_destination_class_types.Port
        },
        ['DestinationFilter'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'U8',
            ['default'] = 0,
            ['validator'] = sync_destination_class_types.DestinationFilter
        }
    },
    ['default_props'] = {['Address'] = '', ['Port'] = 51000, ['DestinationFilter'] = 0}
}

local FileSync = {
    ['prop_configs'] = {
        ['SyncFileList'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'String[]',
            ['default'] = '',
            ['validator'] = file_sync_class_types.SyncFileList
        },
        ['SyncMode'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'U8',
            ['default'] = 0,
            ['validator'] = file_sync_class_types.SyncMode
        },
        ['SyncInterval'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'U8',
            ['default'] = 5,
            ['validator'] = file_sync_class_types.SyncInterval
        },
        ['SyncType'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'U8',
            ['default'] = 1,
            ['validator'] = file_sync_class_types.SyncType
        }
    },
    ['default_props'] = {['SyncFileList'] = '', ['SyncMode'] = 0, ['SyncInterval'] = 5, ['SyncType'] = 1}
}

local M = {}

function M.init(bus)
    class('CANMgmt', CANMgmt):set_bus(bus)
    class('DataSync', DataSync):set_bus(bus)
    class('PropertySync', PropertySync):set_bus(bus)
    class('TCPMgmt', TCPMgmt):set_bus(bus)
    class('SyncDestination', SyncDestination):set_bus(bus)
    class('FileSync', FileSync):set_bus(bus)
end

-- The callback needs to be registered during app initialization
function M.ImplDataSyncDataSyncGetProperties(cb)
    class('DataSync')['bmc.kepler.Managers.DataSync'].GetProperties = function(obj, ctx, ...)
        local req = data_sync_intf_types.GetPropertiesReq.new(...):validate(nil, nil, true)
        local rsp = data_sync_intf_types.GetPropertiesRsp.new(cb(obj, ctx, req:unpack())):validate()
        return rsp:unpack(true)
    end
end

return M
